package com.twenty.seven.webapp.demo.hystix;

import com.twenty.seven.webapp.demo.feign.DemoService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Author twenty-seven
 * @Date 2020/1/14 10:41
 * @TODO
 **/
@Component
public class DemoHystix implements FallbackFactory<DemoService> {

    private static final Logger logger = LoggerFactory.getLogger(DemoHystix.class);

    @Override
    public DemoService create(Throwable throwable) {
        return new DemoService() {
            @Override
            public String getHello() {
                throwable.printStackTrace();
               logger.info("熔断原因："+throwable.getMessage());
                return "熔断了";
            }
        };
    }
}
